<% add_decidim_page_title(t(".title")) %>

<div class="card">

  <div class="item_show__header">
    <h1 class="item_show__header-title">
      <%= t(".title") %>
    </h1>
  </div>

  <div class="table-stacked">
    <table class="table-list">
      <thead>
        <tr>
          <th><%= t(".username") %></th>
          <th><%= t(".address") %></th>
          <th><%= t(".verification_code") %></th>
          <th><%= t(".letter_sent_at") %></th>
          <th><%= t("decidim.admin.actions.actions") %></th>
        </tr>
      </thead>
      <tbody>
        <% @pending_authorizations.each do |authorization| %>
          <tr>
            <td data-label="<%= t(".username") %>">
              <%= authorization.user.name %>
            </td>
            <td data-label="<%= t(".address") %>">
              <%= authorization.verification_address %>
            </td>
            <td data-label="<%= t(".verification_code") %>">
              <%= authorization.verification_code %>
            </td>
            <td data-label="<%= t(".letter_sent_at") %>">
              <%= authorization.letter_sent_at %>
            </td>
            <td class="table-list__actions" data-label="<%= t("decidim.admin.actions.actions") %>">
              <button type="button" data-controller="dropdown" data-target="actions-authorization-<%= authorization.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: authorization.user.name) %>">
                <%= icon "more-fill", class: "text-secondary" %>
              </button>

              <div class="inline-block relative">
                <ul id="actions-authorization-<%= authorization.id %>" class="dropdown dropdown__action" aria-hidden="true">
                  <li class="dropdown__item">
                    <% if authorization.letter_sent? %>
                      <div class="dropdown__button-disabled">
                        <%= with_tooltip t(".already_sent") do %>
                          <%= icon "checkbox-circle-line", class: "text-gray" %>
                          <span>
                            <%= t(".mark_as_sent") %>
                          </span>
                        <% end %>
                      </div>
                    <% else %>
                      <%= link_to pending_authorization_postage_path(authorization.id), method: :post, class: "dropdown__button" do %>
                        <%= icon "checkbox-circle-line" %>
                        <%= t(".mark_as_sent") %>
                      <% end %>
                    <% end %>
                  </li>
                </ul>
              </div>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
